package org.example.service.impl;

import org.example.dao.BlockchainDao;
import org.example.entity.BlockchainRecord;
import org.example.service.BlockchainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlockchainServiceImpl implements BlockchainService {

    private final BlockchainDao blockchainDao;

    @Autowired
    public BlockchainServiceImpl(BlockchainDao blockchainDao) {
        this.blockchainDao = blockchainDao;
    }

    @Override
    public List<BlockchainRecord> getAllBlockchainRecords() {
        return blockchainDao.selectAllRecords();
    }

    @Override
    public BlockchainRecord getBlockchainRecordById(Integer id) {
        return blockchainDao.selectRecordById(id);
    }

    @Override
    public void addBlockchainRecord(BlockchainRecord record) {
        blockchainDao.insertRecord(record);
    }

    @Override
    public BlockchainRecord getBlockchainRecordByTransactionHash(String transactionHash) {
        return blockchainDao.selectRecordByTransactionHash(transactionHash);
    }
}
